from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline

# 加载模型和分词器
model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

# 创建 pipeline
classifier = pipeline('text-classification', model=model, tokenizer=tokenizer)

# 测试
result = classifier("I love this product!")
print(result)
#这个结果表明，模型根据输入的文本 "I love this product!" 预测其情感为 5星，并且对这个预测有较高的信心（91.35%）。